package Thread.Thread_State;

/**
 * 从运行态转到就绪态
 */
public class YieldTest {
    public static void main(String[] args) {
        Thread t1=new Thread(()->{
            while (true){
                System.out.println(Thread.currentThread().getName());
                //线程一就会让出CPU进入就绪态，等待被CPU继续调用
                Thread.yield();
            }
        },"线程一~~");
        t1.start();
        Thread t2=new Thread(()->{
            while (true){
                System.out.println(Thread.currentThread().getName());
            }
        },"线程二~~");
        t2.start();
    }
}
